"""
发送post请求
    url,请求头，请求体
"""
import requests

# 请求url,拷贝地址去掉_o
url = 'http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule'
# 模拟浏览器
h = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
}
# 请求体数据
data = {
    'i': '翻译',
    'from': 'AUTO',
    'to': 'AUTO',
    'smartresult': 'dict',
    'client': 'fanyideskweb',
    'salt': '16064422328461',
    'sign': 'ad44488648b3c36657e3cf9cb73208d4',
    'lts': '1606442232846',
    'bv': 'f7d97c24a497388db1420108e6c3537b',
    'doctype': 'json',
    'version': '2.1',
    'keyfrom': 'fanyi.web',
    'action': 'FY_BY_REALTlME',
}
#利用requests发送post请求爬取数据
response = requests.post(url, headers=h, data=data)
# 打印结果
print(response.content.decode())
